#include "label.h"
#include <QMouseEvent>
#include <QDebug>

Label::Label(QWidget* parent)
    :QLabel(parent)
{

}

void Label::mousePressEvent(QMouseEvent *event)
{
    if(event->button() == Qt::LeftButton)
        qDebug() << "按下鼠标左键";
    else if(event->button() == Qt::RightButton)
        qDebug() << "按下鼠标右键";
    else if(event->button() == Qt::MidButton)
        qDebug() << "按下鼠标滑轮";
    else if(event->button() == Qt::XButton1)
        qDebug() << "按下鼠标侧键1";
    else if(event->button() == Qt::XButton2)
        qDebug() << "按下鼠标侧键2";

//    // label窗口内的范围
//    qDebug() << event->x() << ", " << event->y();

//    // 整个屏幕的范围
//    qDebug() << event->globalX() << ", " << event->globalY();
}

void Label::mouseReleaseEvent(QMouseEvent *event)
{
    if(event->button() == Qt::LeftButton)
        qDebug() << "释放鼠标左键";
    else if(event->button() == Qt::RightButton)
        qDebug() << "释放鼠标右键";
    else if(event->button() == Qt::MidButton)
        qDebug() << "释放鼠标滑轮";
    else if(event->button() == Qt::XButton1)
        qDebug() << "释放鼠标侧键1";
    else if(event->button() == Qt::XButton2)
        qDebug() << "释放鼠标侧键2";
}

void Label::mouseDoubleClickEvent(QMouseEvent *event)
{
    if(event->button() == Qt::LeftButton)
        qDebug() << "双击鼠标左键";
    else if(event->button() == Qt::RightButton)
        qDebug() << "双击鼠标右键";
    else if(event->button() == Qt::MidButton)
        qDebug() << "双击鼠标滑轮";
    else if(event->button() == Qt::XButton1)
        qDebug() << "双击鼠标侧键1";
    else if(event->button() == Qt::XButton2)
        qDebug() << "双击鼠标侧键2";
}
